<?php
class spiderModel extends commonModel
{
    public function __construct()
    {
        parent::__construct();
    }

    //获取tag列表
    public function spider_list($where,$limit,$order)
    {
        $sql="
        SELECT * 
        FROM {$this->model->pre}bot_access 
        ORDER BY {$order}
        LIMIT {$limit} 
        ";
        return $this->model->query($sql); 
    }

    //获取蜘蛛总数
    public function count($where=null)
    {
        return $this->model->table('bot_access')->where()->count();
    }
	
	public function get_bot_name($id){
		if(!$id) return false;
		$bot_array=$this->cache_read('botlist.php');
		if(!is_array($bot_array)) return false;
		$bot_name='';
		foreach($bot_array as $k=>$v){
			if(intval($bot_array[$k]['id'])==intval($id)){
				$bot_name=$bot_array[$k]['name'];
			}
		}
		return $bot_name;
	}
	    //删除蜘蛛记录
    public function del($id)
    {
        return $this->model->table('bot_access')->where('id='.$id)->delete(); 
    }

	private function cache_read($file, $path = '', $iscachevar = 0){
		/*if(!$path) $path = __PUBLICURL__.'/';
		$cachefile = $path.$file;
		//die($cachefile);
		if(file_exists($cachefile)){
			return @include $cachefile;
		}else{
			echo '读取配置文件出错';exit;	
		}*/
		return array (
		  1 => 
		  array (
			'id' => '1',
			'name' => '百度',
			'biaoji' => 'baiduspider',
		  ),
		  2 => 
		  array (
			'id' => '2',
			'name' => '谷哥',
			'biaoji' => 'googlebot',
		  ),
		  3 => 
		  array (
			'id' => '3',
			'name' => '搜狗',
			'biaoji' => 'sogou spider',
		  ),
		  4 => 
		  array (
			'id' => '4',
			'name' => '雅虎',
			'biaoji' => 'slurp',
		  ),
		  5 => 
		  array (
			'id' => '5',
			'name' => 'MSN',
			'biaoji' => 'msnbot',
		  ),
		  6 => 
		  array (
			'id' => '6',
			'name' => '搜狐',
			'biaoji' => 'sohu-search',
		  ),
		  7 => 
		  array (
			'id' => '7',
			'name' => '有道',
			'biaoji' => 'youdaobot',
		  ),
		  8 => 
		  array (
			'id' => '8',
			'name' => 'SOSO',
			'biaoji' => 'sosospider',
		  ),
		  9 => 
		  array (
			'id' => '9',
			'name' => 'Alexa',
			'biaoji' => 'alexa',
		  ),
		);


	}

}

?>